package org.example.reactive.demo1.config;


import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.result.condition.RequestConditionHolder;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;

/**
 * @author Gong.Yang
 */
@Slf4j
@Component
public class GlobleWebFilter implements WebFilter {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
        exchange.getResponse().getHeaders().add("web-filter", "web-filter-test");
        log.info("【全局filter】 before");
        return chain.filter(exchange).doOnTerminate(()->{
            log.info("【全局filter】 after");
        });
    }
}
